package com.ruoyi.util;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

public class WebUtil {

    public static String GetUrl(String url) {
        String result = "";
        BufferedReader read = null;

        try {
            URL realurl = new URL(url);
            URLConnection connection = realurl.openConnection();
            connection.setRequestProperty("accept", "*/*");
            connection.setRequestProperty("connection", "Keep-Alive");
            //connection.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
            connection.setRequestProperty("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36");
            //connection.setRequestProperty("referer","https://www.pixiv.net/");
            connection.connect();
            Map<String, List<String>> map = connection.getHeaderFields();

            String var8;
            for(Iterator var7 = map.keySet().iterator(); var7.hasNext(); var8 = (String)var7.next()) {
                ;
            }

            String line;
            for(read = new BufferedReader(new InputStreamReader(connection.getInputStream(), "utf-8")); (line = read.readLine()) != null; result = result + line) {
                ;
            }
        } catch (Exception var17) {
            var17.printStackTrace();
        } finally {
            if (read != null) {
                try {
                    read.close();
                } catch (Exception var16) {
                    var16.printStackTrace();
                }
            }

        }

        return result;
    }
}
